package com.example.design.shejimoshi.structure.facade;

import com.example.design.shejimoshi.structure.facade.pojo.GiftInfo;

/**
 * 创建外观角色GiftFacadeService类，对外只开放一个月换礼物的exchange()方法，在exchange()方法内部整合3个子系统的所有功能
 */
public class GiftFacadeService {
    private QualifyService qualifyService = new QualifyService();
    private PaymentService paymentService = new PaymentService();
    private ShippingService shippingService = new ShippingService();

    public void exchange(GiftInfo giftInfo){
        if(qualifyService.isAvailable(giftInfo)){
            if(paymentService.pay(giftInfo)){
                String shippingNo = shippingService.delivery(giftInfo);
                System.out.println("物流系统下单成功，物流单号是：" + shippingNo);
            }
        }
    } 
}
